package ai.people.netmon.facebook.view.service.impl;

import ai.people.netmon.facebook.view.mapper.FacebookAccountViewMapper;
import ai.people.netmon.facebook.view.service.FacebookAccountViewService;
import ai.people.netmon.framework.domain.facebook.view.entity.FacebookAccountView;
import ai.people.netmon.framework.domain.facebook.view.request.QueryViewRequest;
import ai.people.netmon.framework.domain.twitter.probe.request.UserWebRequest;
import ai.people.netmon.framework.domain.youtube.view.YoutubeAccountView;
import ai.people.netmon.framework.model.response.PageResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 说明
 *
 * @author zhenglin
 * @since 2022/3/18
 */
@Service
public class FacebookAccountViewServiceImpl extends ServiceImpl<FacebookAccountViewMapper, FacebookAccountView> implements FacebookAccountViewService {

    @Autowired
    FacebookAccountViewMapper viewMapper;

    @Override
    public PageResponse<FacebookAccountView> listViews(QueryViewRequest request) {
        Page<FacebookAccountView> page = new Page<>(request.getOriginPageNo(),request.getPageSize());
        IPage<FacebookAccountView> result = viewMapper.selectPageCustom(page,request);
        return PageResponse.builder(result);
    }

    @Override
    public FacebookAccountView getView(String accountName) {
        LambdaQueryWrapper<FacebookAccountView> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(FacebookAccountView::getAccountName,accountName);
        return getOne(queryWrapper);
    }
}
